﻿using System.Collections.Generic;
using System.Linq;
using Looptribe.Moodlin8.Model;

namespace Looptribe.Moodlin8.ViewModel
{
    public class CourseContentWrapper
    {
        private readonly CourseContent _courseContent;
        public CourseContent Content { get { return _courseContent; } }

        private readonly IList<ModuleContentWrapper> _moduleContents = new List<ModuleContentWrapper>();
        public IEnumerable<ModuleContentWrapper> ModuleContents
        {
            get { return _moduleContents; }
        }

        public CourseContentWrapper(CourseContent courseContent)
        {
            _courseContent = courseContent;

            foreach (var module in Content.Modules)
                if (module.Contents != null)
                    foreach (var content in module.Contents)
                        _moduleContents.Add(new ModuleContentWrapper(module, content));
        }

        public string Title { get { return _courseContent.Name; } }
        public string Subtitle { get { return _courseContent.Summary; } }
    }
}
